// 统一日志工具
export class Logger {
  private static isDevelopment = process.env.NODE_ENV === 'development';

  static info(message: string, ...args: unknown[]): void {
    if (this.isDevelopment) {
      console.info(`[INFO] ${message}`, ...args);
    }
  }

  static error(message: string, error?: unknown): void {
    if (this.isDevelopment) {
      console.error(`[ERROR] ${message}`, error);
    }
    // 在生产环境中，可以将错误发送到日志服务
  }

  static warn(message: string, ...args: unknown[]): void {
    if (this.isDevelopment) {
      console.warn(`[WARN] ${message}`, ...args);
    }
  }

  static debug(message: string, ...args: unknown[]): void {
    if (this.isDevelopment) {
      console.debug(`[DEBUG] ${message}`, ...args);
    }
  }
}

// 简化的日志函数
export const log = {
  info: Logger.info.bind(Logger),
  error: Logger.error.bind(Logger),
  warn: Logger.warn.bind(Logger),
  debug: Logger.debug.bind(Logger),
};